package controllers

import (
	"github.com/astaxie/beego"
	"forhouyu/models"
)

type SystemController struct {
	beego.Controller
}

/**
登陆界面
 */
func (this *SystemController) LoginView() {
	this.TplName = "login.html"
}

/**
登陆动作
 */
func (this *SystemController) Login() {
	username := this.GetString("username")
	password := this.GetString("password")


	ok,msg,user := models.GetUserByUsername(username,password)
	this.SetSession("User",user)

	if ok {
		this.Data["User"] = user
		this.Layout = "index.html"
		this.TplName = "cert_qysb.html"
	}else{
		this.Data["loginerr"] = msg
		this.TplName = "login.html"
	}
}

